import { ResPage, Tree } from "@/api/interface/index";
import { PORT1, TreePort } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 用户管理模块
 */
// 获取区域列表
export const getSpecList = (params: Tree.ReqSpecParams) => {
  console.log(params, "params");
  const { page, pageSize, ...otherParams } = params;
  return http.post<ResPage<Tree.ResSpecList>>(TreePort + `/planting-tree-specification/pageList`, {
    page: page,
    pageSize: pageSize,
    search_key: {
      ...otherParams
      // planting_tree_id: params.planting_tree_id,
      // name: params.name,
      // planting_tree_name: params.planting_tree_name,
      // status: params.status,
      // donate_amount: params.donate_amount,
      // memo: params.memo,
      // sort: params.sort,
      // created_at: params.created_at,
      // updated_at: params.updated_at
    }
  });
};

// 获取树形用户列表
// export const getUserTreeList = (params: Tree.ReqSpecParams) => {
//   return http.post<ResPage<Tree.ResAreaList>>(PORT1 + `/Tree/tree/list`, params);
// };

// 新增用户
// export const addUser = (params: { id: string }) => {
//   return http.post(PORT1 + `/Tree/add`, params);
// };

// 新增区域
export const addSpec = (params: { id: string }) => {
  return http.post(TreePort + `/planting-tree-specification/add`, params);
};
// 批量添加用户
export const BatchAddUser = (params: FormData) => {
  return http.post(PORT1 + `/Tree/import`, params);
};

// 编辑用户
// export const editUser = (params: { id: string }) => {
//   return http.post(PORT1 + `/Tree/edit`, params);
// };

// 编辑区域
export const editSpec = (params: { id: string }) => {
  return http.post(TreePort + `/planting-tree-specification/update`, params);
};

// 删除用户
export const deleteUser = (params: { id: string[] }) => {
  return http.post(PORT1 + `/Tree/delete`, params);
};
// 删除区域
export const deleteSpec = (params: { id: string[] }) => {
  return http.post(TreePort + `/planting-tree-specification/delete`, params);
};
